package com.stone.ble.database;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;

public interface DBController {
	public static final String DB_NAME = "stone.db";
	public static final int DB_VERSION = 3;

	/**
	 * ---open database---
	 * 
	 * @return DBController
	 * @throws SQLException
	 */
	public DBController open() throws SQLException;

	/**
	 * ---close database---
	 * 
	 */
	public void close();

	/**
	 * delete table
	 * 
	 * @throws SQLException
	 */
	public void dropTable(String tableName) throws SQLException;

	/**
	 * ---store data to db---
	 * 
	 * @param tableName
	 * @param initialValues
	 * @return
	 */
	public long save(String tableName, ContentValues contentValues);

	/**
	 * ---update table---
	 * 
	 * @param tableName
	 * @param whereClause
	 * @param args
	 * @return
	 */
	public boolean update(String tableName, String whereClause,
			ContentValues contentValues);

	/**
	 * query
	 * 
	 * @param tableName
	 * @param columns
	 * @param querySql
	 * @return
	 */
	public android.database.Cursor query(String tableName, String[] columns,
			String querySql);
	public android.database.Cursor rawQuery(String sql, String[] columns);
	public android.database.Cursor queryLimit(String tableName,
			String[] columns, String querySql, String limit,String orderBy);

	/**
	 * query all
	 * 
	 * @param tableName
	 * @param columns
	 * @return
	 */
	public Cursor queryAll(String tableName, String[] columns);

	/**
	 * ---delete clause---
	 * 
	 * @param tableName
	 * @param whereClause
	 * @return
	 */
	public boolean delete(String tableName, String whereClause);

	public void init(Context context, String dbName, int dbVersion,
			int dataScriptId);
}
